# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=libcmis
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.5.1
pkgrel=1
arch=('any')
pkgdesc="C/C++ client library for the CMIS interface (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-boost"
         "${MINGW_PACKAGE_PREFIX}-curl"
         "${MINGW_PACKAGE_PREFIX}-cppunit")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
options=('strip' 'staticlibs')
license=("LGPL 2.1")
url="https://github.com/tdf/libcmis"
source=(https://github.com/tdf/${_realname}/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz)
sha256sums=('6acbdf22ecdbaba37728729b75bfc085ee5a4b49a6024757cfb86ccd3da27b0e')

prepare() {
  cd ${_realname}-${pkgver}

  touch README
  autoreconf -fi
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --without-man
  make
}

package() {
  cd "$srcdir/build-${MINGW_CHOST}"
  make DESTDIR=$pkgdir install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING.GPL" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.GPL"
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING.LGPL" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.LGPL"
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING.MPL" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.MPL"
}
